﻿using System;
using System.Collections.Generic;

using DigitalQuran.Data.Metadata;

namespace DigitalQuran.Collection
{
    /// <summary>
    /// Collection of <see cref="DigitalQuran.Prostration"/>
    /// </summary>
    public class ProstrationCollection : ReadOnlyCollection<Prostration>
    {
        /// <summary>
        /// Total Prostration in Qur'an
        /// </summary>
        public const int TotalProstrations = 15;

        internal ProstrationCollection() : base(TotalProstrations) { }

        public override Prostration this[int index]
        {
            get { return _Prostration[index]; }
        }

        public override IEnumerator<Prostration> GetEnumerator()
        {
            foreach (var item in _Prostration)
            {
                yield return item;
            }
        }

        static Prostration[] _Prostration = new Prostration[TotalProstrations];
        internal static void LoadData(IEnumerator<ProstrationMeta> e)
        {
            for (int i = 0; i < TotalProstrations; i++)
            {
                e.MoveNext();
                _Prostration[i] = new Prostration(i, e.Current.VerseNo, e.Current.Type);
            }
        }
    }
}